package com.wo.cloud.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wo.cloud.admin.entity.SysLog;
import com.wo.cloud.admin.service.ISysLogService;
import com.wo.cloud.admin.util.SysFeignConstant;
import com.wo.cloud.admin.vo.SysLogVo;
import com.wo.cloud.core.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2021/4/30 10:02
 * Description: 接口日志管理
 */
@Api(tags = "日志模块")
@RestController
@RequestMapping(SysFeignConstant.SYS_LOG_BASE_URL)
public class SysLogController {

    @Autowired
    private ISysLogService sysLogService;

    // 删除
    @ApiOperation(value = "删除日志")
    @DeleteMapping("/{id}")
    public Response<Object> delete(@PathVariable("id") String id){
        boolean removeById = sysLogService.removeById(id);
        if (!removeById){
            return Response.fail();
        }
        return Response.success();
    }

    // 分页展示
    @ApiOperation(value = "分页展示")
    @PutMapping("/page")
    public Response<Object> page(Page page, @RequestBody SysLogVo sysLogVo){
        IPage<SysLog> sysLogIPage = sysLogService.selectPage(page, sysLogVo);
        return Response.data(sysLogIPage);
    }

}
